/* JAVASCRIPT GOOGLE CHART */

var chart_themes;
var chart_centers;

google.load('visualization', '1', {packages:['imagepiechart']});
google.load('visualization', '1', {packages:['imagelinechart']});


function initialize_charts() {
	chart_themes = new google.visualization.ImagePieChart(document.getElementById('chart_themes'));
	chart_centers = new google.visualization.ImageLineChart(document.getElementById('chart_centers'));
}

function draw_chart_themes(rows, meeting_name) {
	var color = ["2c6dd2","d22cc0","2abc1b","f31818","d2762c"];
	var data = new google.visualization.DataTable();
	data.addColumn('string', 'Thème');
	data.addColumn('number', 'Pourcentage');
	data.addRows(rows.length);
	for (var i=0; i<rows.length; i++) {
		data.setValue(i, 0, rows[i]["name"]);
		data.setValue(i, 1, parseInt(rows[i]["percent"]));
	}
	chart_themes.draw(data, {colors:color, is3D: true,width: 300, height:180, backgroundColor:'#b7c2c7',
		title: "Proportion des thèmes abordés \n dans le congrés:\n" + meeting_name});
}

function draw_chart_centers(rows) {
	var color = ["ff0000"];
	var data = new google.visualization.DataTable();
	data.addColumn('string', 'Année');
	data.addColumn('number', 'Ouvertures');
	data.addRows(rows.length*2);
	var i=0;
	while (i<rows.length) {
		data.setValue(i*2, 0, rows[i]["anneeDebut"]);
		data.setValue(i*2, 1, parseInt(rows[i]["nombre"]));
		data.setValue(i*2+1, 0, rows[i]["anneeFin"]);
		data.setValue(i*2+1, 1, parseInt(rows[i]["nombre"]));
		i++;
	}
	chart_centers.draw(data, 
			{colors:color,width: 300, height: 180, min: 0, max: 8, legend:"top",
				backgroundColor:"#f6cf7c", title:"Nombre d'ouvertures de centre"});
}